﻿using System.Web;
using System.Web.Mvc;

namespace MvcTestingHelpers {
	/// <summary>
	/// HttpContext implementation that is safe for MVC
	/// </summary>
	public class FakeHttpContext : HttpContextBase {
		private readonly HttpRequestBase request;
		private readonly HttpResponseBase response;
		private readonly HttpSessionStateBase session;

		/// <summary>
		/// Creates an HttpContextBase implementation with default request, response and session
		/// </summary>
		public FakeHttpContext() : this(new FakeHttpRequest(HttpVerbs.Get), new FakeHttpResponse(), new FakeHttpSession()) { }

		/// <summary>
		/// Creates an HttpContextBase implementation with the given request, response and session
		/// </summary>
		public FakeHttpContext(HttpRequestBase request, HttpResponseBase response, HttpSessionStateBase session) {
			this.request = request;
			this.response = response;
			this.session = session;
		}

		public override HttpRequestBase Request { get { return request; } }
		public override HttpResponseBase Response { get { return response; } }
		public override HttpSessionStateBase Session { get { return session; } }
	}
}